Gio._promisify(NM.Client.prototype, 'check_connectivity_async');
const MAX_VISIBLE_NETWORKS = 8;
-var MAX_DEVICE_ITEMS = 4;
// small optimization, to avoid using [] all the time
const NM80211Mode = NM['80211Mode'];
this._deviceType = deviceType;
this._nmDevices = new Set();
-
- this._summaryItem = new PopupMenu.PopupSubMenuMenuItem('', true);
- this._summaryItem.icon.icon_name = this._getSummaryIcon();
- this.addMenuItem(this._summaryItem);
-
- this._summaryItem.menu.addSettingsAction(_('Network Settings'),
- 'gnome-network-panel.desktop');
- this._summaryItem.hide();
}
setClient(client) {
const nItems = this._items.size;
this._items.forEach(item => (item.singleDeviceMode = nItems === 1));
-
- let nDevices = this._itemsSection.box.get_children().reduce(
- (prev, child) => prev + (child.visible ? 1 : 0), 0);
- this._summaryItem.label.text = this._getSummaryLabel(nDevices);
- let shouldSummarize = nDevices > MAX_DEVICE_ITEMS;
- this._summaryItem.visible = shouldSummarize;
- this._itemsSection.actor.visible = !shouldSummarize;
- }
-
- _getSummaryIcon() {
- throw new GObject.NotImplementedError();
- }
-
- _getSummaryLabel() {
- throw new GObject.NotImplementedError();
}
}
_createDeviceMenuItem(device) {
return new NMWirelessDeviceItem(this._client, device);
}
-
- _getSummaryIcon() {
- return 'network-wireless-symbolic';
- }
-
- _getSummaryLabel(nDevices) {
- return ngettext(
- '%s Wi-Fi Connection',
- '%s Wi-Fi Connections',
- nDevices).format(nDevices);
- }
}
class NMWiredSection extends NMDeviceSection {
_createDeviceMenuItem(device) {
return new NMWiredDeviceItem(this._client, device);
}
-
- _getSummaryIcon() {
- return 'network-wired-symbolic';
- }
-
- _getSummaryLabel(nDevices) {
- return ngettext(
- '%s Wired Connection',
- '%s Wired Connections',
- nDevices).format(nDevices);
- }
}
class NMBluetoothSection extends NMDeviceSection {
_createDeviceMenuItem(device) {
return new NMBluetoothDeviceItem(this._client, device);
}
-
- _getSummaryIcon() {
- return 'network-wireless-symbolic';
- }
-
- _getSummaryLabel(nDevices) {
- return ngettext(
- '%s Bluetooth Connection',
- '%s Bluetooth Connections',
- nDevices).format(nDevices);
- }
}
class NMModemSection extends NMDeviceSection {
return new NMModemDeviceItem(this._client, device);
}
- _getSummaryIcon() {
- return 'network-wireless-symbolic';
- }
-
- _getSummaryLabel(nDevices) {
- return ngettext(
- '%s Modem Connection',
- '%s Modem Connections',
- nDevices).format(nDevices);
- }
-
_sync() {
super._sync();